/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2303 - Arr5
 * <p>Powered by webrx On 2023-07-12 16:02:44
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr6 {
    public static void main(String[] args) {
        var n1 = new int[10];
        System.out.println(Arrays.toString(n1));
        Arrays.fill(n1, 11);
        //数组n1从下标5开始到8不包括8，填充12
        Arrays.fill(n1, 5, 8, 12);
        System.out.println(Arrays.toString(n1));

        var n2 = new int[]{10, 20};
        var n3 = add(n2, 100);
        System.out.println(Arrays.toString(n3));
    }

    public static int[] add(int[] ns, int num) {
        int[] t = new int[ns.length + 1];
        for (int i = 0; i < ns.length; i++) {
            t[i] = ns[i];
        }
        t[t.length - 1] = num;
        return t;
    }
}
